//创建一个路由器，并暴露出去

//第一步：引入createRouter
import {createRouter,createWebHistory} from "vue-router";
//引入一个个可能要呈现的组件
import Home from "@/views/Home.vue";
import About from "@/views/About.vue";
import News from "@/views/News.vue";
import Detail from "@/views/Detail.vue";
//第二步：创建路由器
let router = createRouter({
    history:createWebHistory(),//路由器的工作模式
    routes:[//一个个的路由规则
        {
            path:'/',
            name:'home',
            components: {
                default: Home,
                top: ()=>import('@/views/Detail.vue')
            }
        },
        {
            path:'/about',
            name:'about',
            component:About,
            children:[
                {// 【?】是可选参数，可传可不传
                    name:'detail',
                    path:'detail/:id/:title/:content?',
                    component:Detail
                }
            ]
        },
        {
            path:'/news',
            name:'news',
            component:News
        },
    ]
})

export default router